import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.ie.service import Service

# 实例化浏览器驱动
service = Service("C:/Program Files/Google/Chrome/Application/chromedriver.exe")
driver = webdriver.Chrome(service=service)
driver.maximize_window() # 最大化窗口
driver.implicitly_wait(10) # 隐式等待
driver.get("http://192.168.10.139/Home/user/login.html")

# 1.进入登录页面, 输入一个不存在的用户名
driver.find_element(By.ID, "username").send_keys("182000333")

# 2.输入密码
driver.find_element(By.ID, "password").send_keys("123456")

# 3.输入验证码
driver.find_element(By.ID, "verify_code").send_keys("8888")

# 4.点击登录按钮
driver.find_element(By.CLASS_NAME, "J-login-submit").click()

# 5.获取错误提示信息
msg = driver.find_element(By.CLASS_NAME, "layui-layer-content").text
print(msg)

# 关闭浏览器
time.sleep(2)
driver.close()